﻿<h1>Web Socket</h1>
<div style="margin: 5px 0px;">
    Server Address:<input id="address" type="text" value="ws://192.168.68.38:8080" style="width: 400px;" />
</div>
<div style="margin: 5px 0px;">
    Your Name:<input id="name" type="text" style="width: 100px;" />
</div>
<div>
    <button id="connect" onclick="connect();">连接服务器</button>
    <button id="disconnect" onclick="quit();">断开服务器</button>
    <button id="clear" onclick="clearMsg();">清空消息</button>
</div>
<h5 style="margin: 4px 0px;">Msg:</h5>
<div id="message" style="border: solid 1px #333; padding: 4px; width: 400px; overflow: auto; background-color: #404040; height: 300px; margin-bottom: 8px; font-size: 14px;">
</div>
<input id="text" type="text" style="width:340px"/>
<button id="send" onclick="send();">send</button>
<script src="../Resource/JS/Module/Chat/Chat.js"></script>
<script>
    var _processChat = new ProcessChat();
    document.getElementById("connect").addEventListener("click", function () { _processChat.connect(); }, false);
    document.getElementById("disconnect").addEventListener("click", function () { _processChat.quit(); }, false);
    document.getElementById("clear").addEventListener("click", function () { _processChat.clearMsg(); }, false);
    document.getElementById("send").addEventListener("click", function () { _processChat.send(); }, false);
    document.getElementById("text").addEventListener("keydown", function (e) {
        if (e.keyCode == 13) {
            _processChat.send();
        } 
    }, false);
</script>